package cn.meibang.meibanguserandclient.provider.service;

import cn.apestar.core.base.BaseService;
import cn.apestar.core.base.GenericMapper;
import cn.meibang.meibanguserandclient.api.IMeibangUserAndClientAPIService;
import cn.meibang.meibanguserandclient.provider.dao.MeibangUserAndClientMapper;
import cn.meibang.meibanguserandclient.provider.domain.MeibangUserAndClient;
import cn.meibang.meibanguserandclient.provider.request.ListMeibangUserAndClientRequest;
import cn.meibang.meibanguserandclient.provider.request.MeibangUserAndClientRequest;
import cn.meibang.meibanguserandclient.provider.response.MeibangUserAndClientResponse;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 业务管理客 <br>
 *
 * @author yudw
 * @version 1.0
 */
@Service public class MeibangUserAndClientService extends BaseService<MeibangUserAndClient, Long>
    implements IMeibangUserAndClientAPIService {

    private Logger logger = LoggerFactory.getLogger(MeibangUserAndClientService.class);

    @Autowired private MeibangUserAndClientMapper meibangUserAndClientMapper;

    @Override protected GenericMapper<MeibangUserAndClient, Long> getMapper() {
        // TODO Auto-generated method stub
        return meibangUserAndClientMapper;
    }

    public void addorUpdate(MeibangUserAndClientRequest record) {
        if (record.getId() == null) {
            if (list(record).size() == 0)
                super.add(record);
        } else
            super.update(record);
    }

    public void del(Long id) {
        MeibangUserAndClientRequest model = new MeibangUserAndClientRequest();
        model.setId(id);
        super.delete(model);
    }

    public List<MeibangUserAndClientResponse> lisForPage(ListMeibangUserAndClientRequest request) {
        List<MeibangUserAndClientResponse> list = meibangUserAndClientMapper.lisForPage(request);
        return list;
    }

    public List<MeibangUserAndClientResponse> list(MeibangUserAndClientRequest request) {
        return meibangUserAndClientMapper.list(request);
    }

    public void insertList(List<MeibangUserAndClientRequest> list) {
        meibangUserAndClientMapper.insertList(list);
    }
}